﻿@{
    ViewBag.Title = "Index";
}

<table class="table">
</table>

@section styles{
    @Styles.Render("~/Content/bootstrapTable")
}
@section scripts{
    @Scripts.Render("~/bundles/jqueryExport")
    @Scripts.Render("~/bundles/bootstrapTable")
    <script type="text/javascript">
        $.bsTable({
            url: "/ArticleType/Select",
            bsToolbar: {
                events: function ($sender, type, ids) {
                    if (type === "click") {
                        if ($sender.hasClass("insert")) {
                            //在这里写添加功能
                            console.log("添加数据");
                        }
                        else if ($sender.hasClass("delete")) {
                            if (ids.length > 0) {
                                //在这里写删除功能
                                console.log("删除选中数据id:" + ids);
                            } else {
                                console.log("请先选择数据");
                            }
                        }
                    }
                }
            },
            tableEvents: tableClick,
            columns: [
            {
                field: 'Id',
                title: '编号'
            },
            {
                field: 'Name',
                title: '分类名称',
            },
            {
                field: 'Count',
                title: '文章数量',
            }
            ]
        })



        function tableClick($sender, type, $row, id) {
            if (type === "click") {
                if ($sender.hasClass("delete")) {
                    console.log("删除id:" + id);
                    $row.remove();
                }
                if ($sender.hasClass("update")) {
                    console.log("修改id:" + id);
                }
            }
            //console.log(arguments);
        }
    </script>
}

